{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}


{% block title %}账单录入{% endblock %}

{% block page_content %}

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="./static/js/my_js.js"></script>

<form class="form-inline" action="" method="post" name="">
<form action="/index_info" method="post" name="postinfo">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>

    <div class="form-row">
			<div class="col-md-12 ">
				
				<div class="form-group">
					
        <div class="form col-md-3">
            <label>金额</label>
            <input type="text" class="form-control" id="money" name="money" placeholder="交易金额" required/>
        </div>

        <div class="form col-md-3">
            <label>收入/支出</label>
            <select name="income_expense_type_id" class="form-control"  style="width: 100%">
                <option value="1">支出</option>
                <option value="2">收入</option>
            </select>
        </div>
        
        	<div class="col-md-3">
        		<label>收支一级类别</label>
        		<select class="form-control" name="income_expense_class_id" onchange="show_income_expense_id()" id="income_expense_class_id" style="width: 100%" required/>
        				<option value="-1">--请选择--</option>
        				{% if income_expense_class_json %}
                    {% for info in income_expense_class_json %}
                        <option value="{{ info.get('id') }}">{{ info.get('type_name') }}</option>
                    {% endfor %}
                {% endif %}
        		</select>
        	</div>
        	
        	
        	<div class="col-md-3">
        		<label>收支二级类别</label>
        		<select class="form-control" name="income_expense_id" id="income_expense_id" disabled="disabled" style="width: 100%" required/>
        			<option value="">--请选择--</option>
        		</select>
        	</div>
        	
        </div>


        <div class="form-group">

        <div class="form col-md-2">
            <label>支付方式</label>
            <select name="pay_channel_id" class="form-control"  style="width: 100%" required/>
        				{% if pay_channel_json %}
                    {% for info in pay_channel_json %}
                        <option value="{{ info.get('id') }}">{{ info.get('name') }}</option>
                    {% endfor %}
                {% endif %}
            </select>
        </div>
                	
        	<div class="col-md-2">
        		<label>支付来源</label>
        		<select class="form-control" name="account_class_id" onchange="show_account_id({{ user_id }})" id="account_class_id"  style="width: 100%" required/>
        				<option value="-1">--请选择--</option>
        				{% if account_class_json %}
                    {% for info in account_class_json %}
                        <option value="{{ info.get('id') }}">{{ info.get('name') }}</option>
                    {% endfor %}
                {% endif %}
        		</select>
        	</div>
        	
        	
        	<div class="col-md-2">
        		<label>账户名称</label>
        		<select class="form-control" name="account_id" id="account_id" disabled="disabled"  style="width: 100%" required/>
        			<option value="">--请选择--</option>
        		</select>
        	</div>


        <div class="form col-md-2">
            <label>交易日期</label>
            <input class="form-control" type="date" name="date" min="2014-11-18" max="2074-11-18" required/>
        </div>
        
        <div class="form col-md-2">
            <label>备注</label>
            <input type="text" class="form-control" id="remark" name="remark" placeholder="备注">
        </div>
        
        <div class="form col-md-1 col-md-offset-1" >
        	<button type="submit" class="btn btn-primary">提交</button>
        </div>

			</div>
			
			</div>

    </div>

    

  </form>

    <br><br>

<table class="table table-bordered">
        <tr>
            <th>日期</th>
            <th>金额</th>
            <th>收支类型</th>
            <th>收支类别</th>
            <th>账户</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
            {% if json_data %}
                 {% for foo in json_data %}
                    <tr>
                      <td>{{ foo.get('date') }}</td>
                      <td>{{ foo.get('money') }}</td>
                        {% if foo.get('income_expense_type_id') == 1 %}
                        <td>支出</td>
                        {% else %}
                        <td>收入</td>
                        {% endif %}
                        <td>{{ foo.get('type_name') }}</td>
                        <td>{{ foo.get('account_name') }}</td>
                        <td>{{ foo.get('remark') }}</td>
                        <td><a href="/index_info_refund?id={{ foo.id }}">退款</a></td>
                        </tr>
                 {% endfor %}
            {% endif %}

</table>



{% endblock %}
